//==============================================================================
// FileUtils.hh
//----------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
// $Id: $
//------------------------------------------------------------------------------
// $Log: $
//   
//==============================================================================
//.......1.........2.........3.........4.........5.........6.........7.........8
//

#include "LocalSTL.hh"
#include "ParseUtils.hh"
#include "RandomNumberGenerator.hh"

#include<sys/stat.h>
#include<unistd.h>
#include<time.h>

#ifndef _FILE_UTILS
#define _FILE_UTILS


//----------------------------------------------------------------------------
// * FileUtils
//----------------------------------------------------------------------------
// \file 
// Miscellaneous file utilities. A few things that are done often enough 
// to be included for convenience. 
// 

//! @todo Create a more secure temporary file name.



string UniquifyName(string NameStart,string NameEnd);

string GetDateStamp(string FileName);
bool FileExists(string FileName);
int  FileSize(string FileName);
bool FileIsNewerThan(string FileName,int year, int tmonth,int tday);

void OpenOrDie(string FileName,ifstream &fin);
void OpenOrDie(string FileName,ofstream &fin);


string GetFileSuffix(string source);
void ReadFOF(string &FileName,vector<string> &Names);
void ReadFOF(const char* pFile,vector<string> &Names);
void WriteFOF(string &FileName,vector<string> &Names);

class icbtstream : public izipstream{
public:

  bool open(string FileName);
};

/*
class ocbtstream : public ostream{
public:

  bool open(string FileName){
	 if (Contains(FileName,".gz")){

	 }else{


	 }
  }

};
*/

/*
class ozipstream : public zipstreambase, public ostream
{
public:
	ozipstream() {}
	ozipstream(const char* name,
                        int mode=ios::out)
		: zipstreambase(name,mode) {}

	zipstreambuf* rdbuf() {return zipstreambase::rdbuf(); }
	void open(const char* name)
		{zipstreambase::open(name,ios::out);}
};
*/

// Deprecated
//string CreateTemporaryFileName(char *rootName);
//string CreateTemporaryFileName(string rootName);


#endif


